<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <title>医生工作站登录</title>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <style>
    body {
      background-color: #5b84cd;
      font-family: Arial, sans-serif;
      margin: 0;
      padding: 0;

    }

    h1 {
      color: #ffffff;
      text-align: center;
    }

    div {
      background-color: #ffffff;
      border-radius: 10px;
      box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.2);
      margin: 50px auto;
      max-width: 400px;
      padding: 20px;
    }

    input[type="text"], input[type="password"] {
      border: 1px solid #ccc;
      border-radius: 5px;
      display: block;
      font-size: 16px;
      margin-bottom: 20px;
      padding: 8px;
      width: 96%;
    }

    input[type="submit"] {
      background-color: #0066cc;
      border: none;
      border-radius: 5px;
      color: #ffffff;
      cursor: pointer;
      font-size: 16px;
      padding: 10px;
      width: 100%;
    }

    input[type="submit"]:hover {
      background-color: #0f5fb6;
    }
    span{
      color: #EE0A4EFF;
      font-size: 15px;

    }

  </style>

</head>
<body>
<h1>修改密码</h1>
<div>
  <label for="username">用户名：</label>
  <input type="text" id="username" name="username" th:value="${doctor.getDoctorName()}" required readonly>
  <label for="password_new">新密码：</label>
  <input type="password" id="password_new" name="password_new" value="" required>
  <label for="password_confirm">确认新密码：</label>
  <input type="password" id="password_confirm" name="password_confirm" value="" required>
  <input type="submit" value="确认" id="submit">
  <span id="msg" style="text-align: center"></span>
</div>
</body>
<script  src="/script/jquery-1.11.1-min.js"></script>
<script type="text/javascript">
  $("#submit").click(function (){
    var password_new=$("#password_new").val();
    var password_confirm=$("#password_confirm").val();
    if(password_new==""|password_confirm==""){
      alert("请完善信息");
    }
    if(password_new!=password_confirm){
      alert("两次密码必须一致");
    }else{
      $.ajax({
        url:'/changePassword',
        data:{
          password_new:password_new
        },
        dataType:'json',
        type:'post',
        success:function (data){
          if(data.code==1){
            window.location.href="/login";
          }else{
            alert(data.message);
          }
        }
      })
    }
  })
</script>
</html>
